<template>
    <div>
        <div class="listbox">
            <div v-for="(item, index) in listData" :key="index"
                :class="[type == item.key ? 'itemboxactive' : ' itembox']" @click="itemactive(item)">
                <div>{{ item.name }}</div>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    name: 'tab',
    props: {
        listData: {
            type: Array,
            default: ''
        },
        keytype:{
            type:String,
            default:'qb'
        }
    },
    data() {
        return {
            // keytype: 'qb',
            type:'',
            
        }
    },
    mounted(){
        this.type=this.keytype
    },
    methods: {
        itemactive(item) {
            this.type = item.key
            this.$emit('tab-change', item.key)
        }
    },
    watch: {
        keytype(newVal) {
            this.type = newVal
        }
    }
}
</script>

<style scoped>
.listbox {
    display: flex;
    justify-content: space-around;
    align-items: center;
    text-align: center;
    border-bottom: 1px solid #ccc;
}

.itembox {
    padding: 20px 15px;
    margin-top: 3px;
    border-bottom: rpx solid transparent;
}

.itemboxactive {
    padding: 20px 15px;
    margin-top: 3px;
    border-bottom: 1px solid #3772ff;
    color: #3772ff;
}
</style>